#!/bin/bash

#GATK dir
gatk=/picb/lilab/tools/gatk-4.2.6.1/gatk

#Reference dir
reference=/picb/lilab5/share_data/ref/hg38/

##shell options
working_dir=$1
sample=$2

if [ ! -d ${working_dir}/gvcf ]
then mkdir -p ${working_dir}/gvcf
fi

if [ ! -d ${working_dir}/gvcf/tmp/${sample} ]
then mkdir -p ${working_dir}/gvcf/tmp/${sample}
fi

if [ ! -d ${working_dir}/realign ]
then mkdir -p ${working_dir}/realign
fi
 

#Variants Calling
time $gatk HaplotypeCaller \
    -ERC GVCF \
    -R $reference/Homo_sapiens.GRCh38.dna.primary_assembly.fa \
    -I ${working_dir}/bam/bqsr/${sample}.sorted.markdup.BQSR..bam \
    -O ${working_dir}/gvcf/${sample}.HC.g.vcf.gz \
    -bamout ${working_dir}/realign/${sample}.HC.realign.bam \
    --tmp-dir ${working_dir}/gvcf/tmp/${sample}

rm -rf ${working_dir}/gvcf/tmp/${sample}

